<!-- TrainGroupList.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	<title>集团切换</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" href="../../css/mui.min.css" />
	<link rel="stylesheet" href="../../css/base.css"/>
	<!--<link rel="stylesheet" href="../../css/CFNetPP_Base.css">-->
	<style type="text/css" media="screen">
		.mui-table-view-radio .mui-table-view-cell .mui-navigate-right:after{
			color: #18b4ed;
		}

	</style>
</head>
<body>
   <div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%"></div> 
	<div id="header" class="base_navigation_bar base_style_color base_navigation_item_bar">
        <a class="base_left_item" href="#" onclick="backClick()">
            <img class="base_back_icon" src="../../image/icon_jiantou.png" alt="">
        </a>
        <span id="nav_title">集团切换</span>
        <a class="base_right_item base_hide_item">
        </a>
    </div>
    <div id="main" class="base_content_div">
    	<ul id="group_list" class="mui-table-view mui-table-view-radio">
			<li class="mui-table-view-cell mui-selected">
				<a class="mui-navigate-right base_dark_grey base_content_font">
				</a>
			</li>
		</ul>
	</div>
</body>
<script type="text/javascript" src="../../script/mui.min.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript">

    var stdydata = "";
    var dataSource = [];
    var index = "";
	apiready = function(){

        if ($api.getStorage('changfengtype') == 1) {  //学习/教学进来的
            stdydata = $api.getStorage('stdydata');

        }else if ($api.getStorage('changfengtype') == 2){  //实习进来的
            stdydata =  $api.getStorage('practicedata');
	    }

		setupGroupData(stdydata);
	}
	function setupGroupData(groupDatas){
		var groupHtml = '';
		for (var i = 0; i < groupDatas.length; i++) {
			var groupData = groupDatas[i];
			groupHtml += groupHtmlString(groupData);
			
		}
		$('#group_list').html(groupHtml);
		groupCellClick();
	}    
	function groupHtmlString(data){
		var isSelected = "";

		if ($api.getStorage('changfengtype') == 1) {
            var jid = $api.getStorage('cfnetppjxid');
		if (jid == data.id) {
			isSelected = " mui-selected";
		}
		return '<li id="'+data.id+'" class="group_cell mui-table-view-cell'+isSelected+'">\
				<a class="mui-navigate-right base_dark_grey base_content_font">'+
					data.name+
				'</a>\
			</li>';
        }else if ($api.getStorage('changfengtype') == 2) {
            var jid = $api.getStorage('cfnetppjid');
		if (jid == data.id) {
			isSelected = " mui-selected";
		}
		return '<li id="'+data.id+'" class="group_cell mui-table-view-cell'+isSelected+'">\
				<a class="mui-navigate-right base_dark_grey base_content_font">'+
					data.name+
				'</a>\
			</li>';
        }
		
	}
	function groupCellClick(){
		$('.group_cell').unbind('click');
		$('.group_cell').click(function(){
			var currentJid = $(this).attr('id');
			var name = "";
            for (var i = stdydata.length - 1; i >= 0; i--) {
            	if (stdydata[i].id == currentJid) {
            		name = stdydata[i].name;
            		index = i;
            	}
            }

                 
            if ($api.getStorage('changfengtype') == 1) {
            	if (currentJid != $api.getStorage('cfnetppjxid')) {
					
					/*存上选中的xid*/
					$api.setStorage('cfnetppjxid', currentJid);
					$api.setStorage('cfnetppjxidname', name);
                    api.sendEvent({
                        name: 'changeJidNotifi',
                        extra: {
                            jid: currentJid, 
                        }
                    });
                    api.closeToWin({
	                    name:'index',
                   });

                    dataSource = $api.getStorage('stdydata');
                    $api.setStorage('cfnetSelectType',dataSource[index].usertpye); 
                    // alert(JSON.stringify("stdydata"+dataSource[index].usertpye));
                    
		     	}

            }else if ($api.getStorage('changfengtype') == 2){
                if (currentJid != $api.getStorage('cfnetppjid')) {
				
				/*存上选中的jid*/
				$api.setStorage('cfnetppjid', currentJid);
			    $api.setStorage('cfnetppjidname', name);
			        api.sendEvent({
                        name: 'changeJidNotifi',
                        extra: {
                            jid: currentJid, 
                        }
                    });
                    api.closeToWin({
	                    name:'index',
                   });
                    
				dataSource = $api.getStorage('practicedata');
                $api.setStorage('cfnetSelectType',dataSource[index].usertpye); 
                // alert(JSON.stringify("practicedata"+dataSource[index].usertpye));
	     	  }
            }
			

		});
	}
	
	function backClick(){
		api.closeWin();
	}
</script>
</html>
